package com.etc.RCCPA002.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.etc.RCCPA002.vo.BannerVo;


@Mapper
@SuppressWarnings("rawtypes")
public interface AdminBannerMapper {

    @Select(" select * from model_mst ")
    List<Map> findAllModel();

    @Select("<script> SELECT t1.*, t2.modname, t3.uname FROM banner_mst t1 LEFT JOIN model_mst t2  "
            + "   ON t1.modid = t2.id     " + "   LEFT JOIN admin_mst t3  "
            + "   ON t1.cid = t3.id   " + 
            "<where>     " +
     " <if test=\"mobsyn != null and mobsyn != -1\" > " +
      "  and mobsyn = #{mobsyn }      " +
     " </if>   " +
      " <if test=\"statflg != null and statflg != -1\" >     " +
        " and  statflg = #{statflg}     " + 
      " </if> " +
      " <if test=\"title != null and title != ''\" >     " +
        " and title like '%${title}%' " + 
      " </if> " +
      " <if test=\"modid != null and modid != -1 \" >     " +
        " and modid = #{modid,} " +
      "</if> </where>" +  
            "    ORDER BY"
                    + " t1.orderby , t1.cdate desc </script>")
    List<Map> findAllBanner(BannerVo params);
    
    @Update(" update banner_mst set statflg = '${statflg}' where id = ${id} ")
    int updateStatflg(@Param("id")Integer id, @Param("statflg")Integer statflg);

    int updateByPrimaryKeySelective(HashMap data);

    Map selectByPrimaryKey(HashMap data);
    @Select(" select * from banner_mst where id = #{id} ")
    Map selectById(Integer id);
    int deleteByPrimaryKey(Integer id);

    int insertSelective(HashMap data);
    @Select("SELECT t2.id FROM admin_mst t2 WHERE t2.phone = #{username}")
    Integer findUidByPhone(String username);

}
